/*     */ import java.awt.Color;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Font;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.Insets;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
/*     */ import java.awt.geom.Line2D.Double;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.Arrays;
/*     */ import java.util.List;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.Box;
/*     */ import javax.swing.BoxLayout;
/*     */ import javax.swing.JButton;
/*     */ import javax.swing.JDialog;
/*     */ import javax.swing.JFrame;
/*     */ import javax.swing.JLabel;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JPanel;
/*     */ import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
/*     */ 
/*     */ public class MFIChart extends JPanel
/*     */   implements MouseMotionListener, BBIInterface, ActionListener
/*     */ {
/*     */   private SymQuotes sq;
/*     */   private String sym;
/*  14 */   private float yScale = 1.0F;
/*  15 */   private float xScale = 1.0F;
/*     */   private double stickWidth;
/*     */   private float minVal;
/*     */   private float maxVal;
/*     */   private int parm1;
/*     */   private int parm2;
/*     */   private float[] typPrice;
/*     */   private float[] mfi_parm1;
/*     */   private float[] mfiMA_parm2;
/*  22 */   private String m = "";
/*     */   private int mX;
/*     */   private int mY;
/*  24 */   public int noOfDays = 150;
/*     */   private double p1Y;
/*     */   private double p2Y;
/*     */   private double p11Y;
/*     */   private double p22Y;
/*     */   private JTextField parm1TF;
/*     */   private JTextField parm2TF;
/*     */   private JButton chgParmOk;
/*     */   private JButton chgParmCancel;
/*     */   private JButton defaultParms;
/*     */   private JDialog chgParmDialog;
/*  32 */   private DecimalFormat df = new DecimalFormat("0.00");
/*     */ 
/*  34 */   public String trend = "";
/*     */   public MFIChart.EastPanel ep;
/*     */   private double refY;
/*     */   private double refX;
/* 519 */   private Font ssp10 = new Font("SansSerif", 0, 10);
/* 520 */   private Font ssp9 = new Font("SansSerif", 0, 9);
/* 521 */   private Line2D.Double refL1 = new Line2D.Double();
/* 522 */   private Line2D.Double refL2 = new Line2D.Double();
/* 523 */   private Line2D.Double gridY = new Line2D.Double();
/* 524 */   private Line2D.Double gridX = new Line2D.Double();
/* 525 */   private Line2D.Double yrefL1 = new Line2D.Double();
/* 526 */   private Line2D.Double yrefL2 = new Line2D.Double();
/*     */   private double yfactor;
/*     */   private double startPointX;
/*     */   private int dateRef;
/*     */   private int daysRef;
/* 531 */   private Line2D.Double l1 = new Line2D.Double();
/* 532 */   private Line2D.Double l2 = new Line2D.Double();
/*     */   private double x1;
/*     */   private double y1;
/*     */   private double x2;
/*     */   private double y2;
/*     */   private double u1;
/*     */   private double v1;
/*     */   private double u2;
/*     */   private double v2;
/*     */   private double a1;
/*     */   private double b1;
/*     */   private double a2;
/*     */   private double b2;
/*     */   private double xi;
/*     */   private double yi;
/* 534 */   private Line2D.Double uA = new Line2D.Double();
/* 535 */   private Line2D.Double lA = new Line2D.Double();
/* 536 */   private Line2D.Double hA = new Line2D.Double();
/*     */ 
/*     */   public MFIChart(SymQuotes paramSymQuotes, int paramInt1, int paramInt2)
/*     */   {
/*  40 */     this.sq = paramSymQuotes;
/*  41 */     this.sym = paramSymQuotes.sym;
/*     */ 
/*  43 */     this.typPrice = new float[paramSymQuotes.count];
/*  44 */     this.mfi_parm1 = new float[paramSymQuotes.count];
/*  45 */     this.mfiMA_parm2 = new float[paramSymQuotes.count];
/*     */ 
/*  47 */     this.parm1 = paramInt1;
/*  48 */     this.parm2 = paramInt2;
/*     */ 
/*  50 */     if (this.noOfDays == 150)
/*  51 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/*  53 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/*  55 */     setBackground(Color.black);
/*  56 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */ 
/*  58 */     typPrice();
/*     */ 
/*  60 */     if (paramInt1 < paramSymQuotes.count) {
/*  61 */       mfi_parm1Finder();
/*     */     }
/*  63 */     if (paramInt1 + paramInt2 < paramSymQuotes.count) {
/*  64 */       mfiMA_parm2Finder();
/*     */     }
/*  66 */     this.minVal = 0.0F;
/*  67 */     this.maxVal = 100.0F;
/*  68 */     addMouseMotionListener(this);
/*     */ 
/*  70 */     if (this.mfi_parm1[(paramSymQuotes.count - 1)] >= this.mfiMA_parm2[(paramSymQuotes.count - 1)])
/*  71 */       this.trend = "Bullish";
/*     */     else {
/*  73 */       this.trend = "Bearish";
/*     */     }
/*  75 */     this.ep = new MFIChart.EastPanel();
/*     */   }
/*     */ 
/*     */   public int getBBIdata(int paramInt)
/*     */   {
/*  82 */     if (this.mfi_parm1[paramInt] >= this.mfiMA_parm2[paramInt]) {
/*  83 */       return 1;
/*     */     }
/*  85 */     return 0;
/*     */   }
/*     */ 
/*     */   public void changeNoOfDays(int paramInt)
/*     */   {
/*  92 */     this.noOfDays = paramInt;
/*     */ 
/*  94 */     if (paramInt == 150)
/*  95 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/*  97 */       this.stickWidth = (1.5D * this.xScale);
/*     */   }
/*     */ 
/*     */   public void redrawChart(SymQuotes paramSymQuotes)
/*     */   {
/* 104 */     this.sq = paramSymQuotes;
/* 105 */     this.sym = paramSymQuotes.sym;
/*     */ 
/* 107 */     this.typPrice = new float[paramSymQuotes.count];
/* 108 */     this.mfi_parm1 = new float[paramSymQuotes.count];
/* 109 */     this.mfiMA_parm2 = new float[paramSymQuotes.count];
/*     */ 
/* 111 */     if (this.noOfDays == 150)
/* 112 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/* 114 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/* 116 */     typPrice();
/*     */ 
/* 118 */     if (this.parm1 < paramSymQuotes.count) {
/* 119 */       mfi_parm1Finder();
/*     */     }
/* 121 */     if (this.parm1 + this.parm2 < paramSymQuotes.count) {
/* 122 */       mfiMA_parm2Finder();
/*     */     }
/* 124 */     this.minVal = 0.0F;
/* 125 */     this.maxVal = 100.0F;
/*     */ 
/* 127 */     if (this.mfi_parm1[(paramSymQuotes.count - 1)] >= this.mfiMA_parm2[(paramSymQuotes.count - 1)])
/* 128 */       this.trend = "Bullish";
/*     */     else {
/* 130 */       this.trend = "Bearish";
/*     */     }
/* 132 */     repaint();
/* 133 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void redrawChart()
/*     */   {
/* 140 */     Arrays.fill(this.mfi_parm1, 0.0F);
/* 141 */     Arrays.fill(this.mfiMA_parm2, 0.0F);
/*     */ 
/* 143 */     typPrice();
/*     */ 
/* 145 */     if (this.parm1 < this.sq.count) {
/* 146 */       mfi_parm1Finder();
/*     */     }
/* 148 */     if (this.parm1 + this.parm2 < this.sq.count) {
/* 149 */       mfiMA_parm2Finder();
/*     */     }
/* 151 */     this.minVal = 0.0F;
/* 152 */     this.maxVal = 100.0F;
/*     */ 
/* 154 */     if (this.mfi_parm1[(this.sq.count - 1)] >= this.mfiMA_parm2[(this.sq.count - 1)])
/* 155 */       this.trend = "Bullish";
/*     */     else {
/* 157 */       this.trend = "Bearish";
/*     */     }
/* 159 */     repaint();
/* 160 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void mouseMoved(MouseEvent paramMouseEvent)
/*     */   {
/* 168 */     int j = 1;
/* 169 */     if ((paramMouseEvent.getX() >= 50) && (paramMouseEvent.getX() <= 750.0F * this.xScale + 50.0F) && (paramMouseEvent.getY() >= 10) && (paramMouseEvent.getY() <= this.yScale * 100.0F + 10.0F))
/*     */     {
/* 171 */       int i = (int)((750.0F * this.xScale - (paramMouseEvent.getX() - 50) - this.stickWidth / 2.0D) / (this.stickWidth + 1.0F * this.xScale));
/*     */ 
/* 173 */       if (this.sq.count - 1 >= i)
/*     */       {
/* 175 */         j = this.sq.count - 1 - i;
/* 176 */         this.m = ("( " + (String)this.sq.date.get(j) + ", MFI[" + this.parm1 + "]:" + this.df.format(this.mfi_parm1[j]) + "  MFI MA[" + this.parm2 + "]:" + this.df.format(this.mfiMA_parm2[j]) + " )");
/*     */ 
/* 178 */         this.mX = paramMouseEvent.getX();
/* 179 */         this.mY = paramMouseEvent.getY();
/* 180 */         repaint();
/* 181 */         return;
/*     */       }
/*     */ 
/* 185 */       this.m = "";
/*     */ 
/* 187 */       repaint();
/* 188 */       return;
/*     */     }
/*     */ 
/* 192 */     this.m = "";
/* 193 */     repaint();
/*     */   }
/*     */ 
/*     */   public void mouseDragged(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   private void drawValues(Graphics2D paramGraphics2D)
/*     */   {
/* 206 */     paramGraphics2D.setPaint(Color.cyan);
/*     */ 
/* 208 */     if (this.mX + this.m.length() * 5 > 750.0F * this.xScale + 50.0F) {
/* 209 */       this.mX -= this.m.length() * 5;
/*     */     }
/* 211 */     paramGraphics2D.drawString(this.m, this.mX, this.mY);
/*     */   }
/*     */ 
/*     */   private void typPrice()
/*     */   {
/* 218 */     for (int i = 0; i < this.sq.count; i++)
/*     */     {
/* 220 */       this.typPrice[i] = ((((Float)this.sq.high.get(i)).floatValue() + ((Float)this.sq.low.get(i)).floatValue() + ((Float)this.sq.close.get(i)).floatValue()) / 3.0F);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void mfi_parm1Finder()
/*     */   {
/* 229 */     for (int i = 0; i < this.parm1; i++) {
/* 230 */       this.mfi_parm1[i] = 0.0F;
/*     */     }
/* 232 */     for (int i = this.parm1; i < this.sq.count; i++)
/*     */     {
/* 234 */       float f1 = 0.0F;
/* 235 */       float f2 = 0.0F;
/* 236 */       float f3 = 0.0F;
/*     */ 
/* 238 */       for (int j = i; j > i - this.parm1; j--)
/*     */       {
/* 240 */         if (this.typPrice[j] > this.typPrice[(j - 1)]) {
/* 241 */           f1 += this.typPrice[j] * ((Integer)this.sq.qty.get(j)).intValue();
/*     */         }
/* 243 */         if (this.typPrice[j] < this.typPrice[(j - 1)]) {
/* 244 */           f2 += this.typPrice[j] * ((Integer)this.sq.qty.get(j)).intValue();
/*     */         }
/*     */       }
/*     */ 
/* 248 */       if (f2 == 0.0F) {
/* 249 */         this.mfi_parm1[i] = 100.0F;
/*     */       } else {
/* 251 */         f3 = f1 / f2;
/* 252 */         this.mfi_parm1[i] = (100.0F - 100.0F / (1.0F + f3));
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   private void mfiMA_parm2Finder()
/*     */   {
/* 262 */     for (int i = 0; i < this.parm1 + this.parm2; i++) {
/* 263 */       this.mfiMA_parm2[i] = 0.0F;
/*     */     }
/* 265 */     for (int i = this.parm1 + this.parm2; i < this.sq.count; i++)
/*     */     {
/* 267 */       float f = 0.0F;
/* 268 */       for (int j = i; j > i - this.parm2; j--)
/*     */       {
/* 270 */         f += this.mfi_parm1[j];
/*     */       }
/*     */ 
/* 273 */       this.mfiMA_parm2[i] = (f / this.parm2);
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateParms(int paramInt1, int paramInt2)
/*     */   {
/* 281 */     this.parm1 = paramInt1;
/* 282 */     this.parm2 = paramInt2;
/*     */ 
/* 284 */     mfi_parm1Finder();
/* 285 */     mfiMA_parm2Finder();
/*     */   }
/*     */ 
/*     */   public Box getMFIBox(boolean paramBoolean)
/*     */   {
/* 292 */     Box localBox = Box.createHorizontalBox();
/* 293 */     TitledBorder localTitledBorder = BorderFactory.createTitledBorder("MFI");
/*     */ 
/* 295 */     this.parm1TF = new JTextField("" + this.parm1, 2);
/* 296 */     this.parm2TF = new JTextField("" + this.parm2, 2);
/* 297 */     this.parm1TF.setFont(this.ssp10);
/* 298 */     this.parm2TF.setFont(this.ssp10);
/* 299 */     this.parm1TF.setMaximumSize(new Dimension(25, 20));
/* 300 */     this.parm2TF.setMaximumSize(new Dimension(25, 20));
/*     */ 
/* 302 */     JLabel localJLabel1 = new JLabel("MFI[");
/* 303 */     JLabel localJLabel2 = new JLabel("] ,  MFI MA[");
/* 304 */     JLabel localJLabel3 = new JLabel("]     ");
/*     */ 
/* 306 */     localJLabel1.setFont(this.ssp10);
/* 307 */     localJLabel2.setFont(this.ssp10);
/* 308 */     localJLabel3.setFont(this.ssp10);
/*     */ 
/* 310 */     localBox.add(localJLabel1);
/* 311 */     localBox.add(this.parm1TF);
/* 312 */     localBox.add(localJLabel2);
/* 313 */     localBox.add(this.parm2TF);
/* 314 */     localBox.add(localJLabel3);
/*     */ 
/* 316 */     localBox.add(Box.createHorizontalGlue());
/*     */ 
/* 318 */     if (paramBoolean) {
/* 319 */       localBox.setBorder(localTitledBorder);
/*     */     }
/* 321 */     return localBox;
/*     */   }
/*     */ 
/*     */   public void showChgParmDialog()
/*     */   {
/* 328 */     JFrame localJFrame = new JFrame();
/* 329 */     this.chgParmDialog = new JDialog(localJFrame, "Change MFI Parameters", true);
/* 330 */     Box localBox1 = Box.createVerticalBox();
/* 331 */     Box localBox2 = Box.createHorizontalBox();
/*     */ 
/* 333 */     this.chgParmOk = new JButton("OK");
/* 334 */     this.chgParmOk.setFont(this.ssp10);
/* 335 */     this.chgParmOk.setMargin(new Insets(1, 2, 1, 2));
/* 336 */     this.chgParmOk.addActionListener(this);
/*     */ 
/* 338 */     this.chgParmCancel = new JButton("Cancel");
/* 339 */     this.chgParmCancel.setFont(this.ssp10);
/* 340 */     this.chgParmCancel.setMargin(new Insets(1, 2, 1, 2));
/* 341 */     this.chgParmCancel.addActionListener(this);
/*     */ 
/* 343 */     this.defaultParms = new JButton("Default");
/* 344 */     this.defaultParms.setFont(this.ssp10);
/* 345 */     this.defaultParms.setMargin(new Insets(1, 2, 1, 2));
/* 346 */     this.defaultParms.setToolTipText("Reset to default parameters");
/* 347 */     this.defaultParms.addActionListener(this);
/*     */ 
/* 349 */     localBox2.add(Box.createHorizontalGlue());
/* 350 */     localBox2.add(this.chgParmOk);
/* 351 */     localBox2.add(Box.createHorizontalStrut(5));
/* 352 */     localBox2.add(this.chgParmCancel);
/* 353 */     localBox2.add(Box.createHorizontalStrut(5));
/* 354 */     localBox2.add(this.defaultParms);
/* 355 */     localBox2.add(Box.createHorizontalGlue());
/*     */ 
/* 357 */     localBox1.add(getMFIBox(true));
/* 358 */     localBox1.add(localBox2);
/*     */ 
/* 360 */     this.chgParmDialog.getContentPane().add(localBox1);
/* 361 */     this.chgParmDialog.setSize(250, 100);
/* 362 */     this.chgParmDialog.setLocationRelativeTo(this.ep);
/* 363 */     this.chgParmDialog.setVisible(true);
/*     */   }
/*     */ 
/*     */   public boolean validateParm()
/*     */   {
/* 370 */     int i = this.parm1;
/* 371 */     int j = this.parm2;
/*     */     try
/*     */     {
/* 375 */       i = Integer.parseInt(this.parm1TF.getText().trim());
/* 376 */       j = Integer.parseInt(this.parm2TF.getText().trim());
/*     */     }
/*     */     catch (NumberFormatException localNumberFormatException)
/*     */     {
/* 382 */       JOptionPane.showMessageDialog(null, "Error in MFI parameter.Enter only numbers greater than 2.", null, 0);
/*     */ 
/* 385 */       this.parm1TF.setText("" + this.parm1);
/* 386 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 388 */       return false;
/*     */     }
/*     */ 
/* 392 */     if ((i > 200) || (j > 200))
/*     */     {
/* 394 */       JOptionPane.showMessageDialog(null, "Error in MFI parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 397 */       this.parm1TF.setText("" + this.parm1);
/* 398 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 400 */       return false;
/*     */     }
/*     */ 
/* 404 */     if ((i < 2) || (j < 2))
/*     */     {
/* 406 */       JOptionPane.showMessageDialog(null, "Error in MFI parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 409 */       this.parm1TF.setText("" + this.parm1);
/* 410 */       this.parm2TF.setText("" + this.parm2);
/*     */ 
/* 412 */       return false;
/*     */     }
/*     */ 
/* 416 */     this.parm1 = i;
/* 417 */     this.parm2 = j;
/*     */ 
/* 419 */     return true;
/*     */   }
/*     */ 
/*     */   public void actionPerformed(ActionEvent paramActionEvent)
/*     */   {
/* 426 */     if (paramActionEvent.getSource() == this.chgParmOk)
/*     */     {
/* 428 */       if (!validateParm()) {
/* 429 */         return;
/*     */       }
/* 431 */       redrawChart();
/* 432 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 436 */     if (paramActionEvent.getSource() == this.chgParmCancel)
/*     */     {
/* 438 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 442 */     if (paramActionEvent.getSource() == this.defaultParms)
/*     */     {
/* 444 */       setDefaultParms();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDefaultParms()
/*     */   {
/* 453 */     this.parm1TF.setText("14");
/* 454 */     this.parm2TF.setText("10");
/*     */   }
/*     */ 
/*     */   public void vZoom(boolean paramBoolean)
/*     */   {
/* 461 */     if (paramBoolean)
/* 462 */       this.yScale += 0.2F;
/* 463 */     else if (this.yScale >= 1.2F) {
/* 464 */       this.yScale -= 0.2F;
/*     */     }
/* 466 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void hZoom(boolean paramBoolean)
/*     */   {
/* 473 */     if (paramBoolean)
/* 474 */       this.xScale += 0.2F;
/* 475 */     else if (this.xScale >= 1.2F) {
/* 476 */       this.xScale -= 0.2F;
/*     */     }
/* 478 */     if (this.noOfDays == 150)
/* 479 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 481 */       this.stickWidth = (1.5D * this.xScale);
/* 482 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void resetZoom()
/*     */   {
/* 489 */     this.yScale = 1.0F;
/* 490 */     this.xScale = 1.0F;
/* 491 */     if (this.noOfDays == 150)
/* 492 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 494 */       this.stickWidth = (1.5D * this.xScale);
/* 495 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   protected void clear(Graphics paramGraphics)
/*     */   {
/* 502 */     super.paintComponent(paramGraphics);
/*     */   }
/*     */ 
/*     */   protected void paintComponent(Graphics paramGraphics)
/*     */   {
/* 509 */     clear(paramGraphics);
/* 510 */     Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 511 */     drawChart(localGraphics2D);
/* 512 */     drawValues(localGraphics2D);
/*     */   }
/*     */ 
/*     */   private void drawChart(Graphics2D paramGraphics2D)
/*     */   {
/* 542 */     this.refY = 10.0D;
/* 543 */     this.refX = 50.0D;
/* 544 */     setFont(this.ssp10);
/* 545 */     String str = "Money Flow Index";
/* 546 */     paramGraphics2D.setPaint(new Color(100, 240, 250));
/* 547 */     paramGraphics2D.drawString(str, 50, 10);
/*     */ 
/* 549 */     str = "MFI[" + this.parm1 + "]";
/* 550 */     paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 551 */     paramGraphics2D.drawString(str, 145, 10);
/*     */ 
/* 553 */     str = "MFI MA[" + this.parm2 + "]";
/* 554 */     paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 555 */     paramGraphics2D.drawString(str, 195, 10);
/*     */ 
/* 558 */     this.refL1.setLine(50.0D, 10.0D, 50.0D, this.yScale * 100.0F + 10.0F);
/* 559 */     this.refL2.setLine(750.0F * this.xScale + 50.0F, 10.0D, 750.0F * this.xScale + 50.0F, this.yScale * 100.0F + 10.0F);
/* 560 */     paramGraphics2D.setPaint(Color.white);
/* 561 */     paramGraphics2D.draw(this.refL1);
/* 562 */     paramGraphics2D.draw(this.refL2);
/*     */ 
/* 564 */     for (int i = 0; i < 14; i++)
/*     */     {
/* 566 */       this.refX += 50.0F * this.xScale;
/* 567 */       this.gridY.setLine(this.refX, 10.0D, this.refX, this.yScale * 100.0F + 10.0F);
/* 568 */       paramGraphics2D.setPaint(Color.darkGray);
/* 569 */       paramGraphics2D.draw(this.gridY);
/*     */     }
int i;
/*     */ 
/* 573 */     for (i = 0; i < 11; i++)
/*     */     {
/* 575 */       this.yrefL1.setLine(50.0D, this.refY, 40.0D, this.refY);
/* 576 */       str = "" + (int)(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/* 577 */       paramGraphics2D.setPaint(Color.lightGray);
/* 578 */       paramGraphics2D.drawString(str, 30, (int)this.refY);
/* 579 */       this.yrefL2.setLine(750.0F * this.xScale + 50.0F, this.refY, 750.0F * this.xScale + 60.0F, this.refY);
/*     */ 
/* 581 */       paramGraphics2D.drawString(str, (int)(750.0F * this.xScale + 53.0F), (int)this.refY);
/* 582 */       this.gridX.setLine(50.0D, this.refY, 750.0F * this.xScale + 50.0F, this.refY);
/* 583 */       paramGraphics2D.setPaint(Color.white);
/* 584 */       paramGraphics2D.draw(this.yrefL1);
/* 585 */       paramGraphics2D.draw(this.yrefL2);
/* 586 */       if ((i == 2) || (i == 8))
/* 587 */         paramGraphics2D.setPaint(new Color(120, 120, 0));
/*     */       else
/* 589 */         paramGraphics2D.setPaint(Color.darkGray);
/* 590 */       paramGraphics2D.draw(this.gridX);
/* 591 */       this.refY += 10.0F * this.yScale;
/*     */     }
/*     */ 
/* 595 */     this.yfactor = (this.yScale * 100.0F / (this.maxVal - this.minVal));
/* 596 */     this.startPointX = (750.0F * this.xScale + 50.0F - (this.stickWidth + 1.0F * this.xScale));
/* 597 */     this.dateRef = (this.sq.count - 1);
/* 598 */     this.daysRef = 1;
/*     */ 
/* 601 */     for (i = this.sq.count - 1; i > this.parm1; i--)
/*     */     {
/* 603 */       if (this.daysRef == this.noOfDays)
/*     */         break;
/* 605 */       paramGraphics2D.setFont(this.ssp10);
/*     */ 
/* 608 */       if (i > this.parm1 + this.parm2)
/*     */       {
/* 610 */         this.p1Y = (this.yScale * 100.0F + 10.0F - (this.mfiMA_parm2[i] - this.minVal) * this.yfactor);
/* 611 */         this.p2Y = (this.yScale * 100.0F + 10.0F - (this.mfiMA_parm2[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 613 */         this.l1.setLine(this.startPointX, this.p1Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2Y);
/* 614 */         paramGraphics2D.setPaint(new Color(210, 210, 20));
/* 615 */         paramGraphics2D.draw(this.l1);
/*     */       }
/*     */ 
/* 619 */       if (i > this.parm1)
/*     */       {
/* 621 */         this.p11Y = (this.yScale * 100.0F + 10.0F - (this.mfi_parm1[i] - this.minVal) * this.yfactor);
/* 622 */         this.p22Y = (this.yScale * 100.0F + 10.0F - (this.mfi_parm1[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 624 */         this.l2.setLine(this.startPointX, this.p11Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p22Y);
/* 625 */         paramGraphics2D.setPaint(new Color(80, 150, 125));
/* 626 */         paramGraphics2D.draw(this.l2);
/*     */       }
/*     */ 
/* 630 */       if ((i > this.parm1 + this.parm2) && (this.mfi_parm1[i] - this.mfiMA_parm2[i] >= 0.0F) && (this.mfi_parm1[(i - 1)] - this.mfiMA_parm2[(i - 1)] < 0.0F))
/*     */       {
/* 632 */         this.x1 = this.startPointX;
/* 633 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 634 */         this.y1 = this.p1Y;
/* 635 */         this.y2 = this.p2Y;
/* 636 */         this.u1 = this.x1;
/* 637 */         this.u2 = this.x2;
/* 638 */         this.v1 = this.p11Y;
/* 639 */         this.v2 = this.p22Y;
/*     */ 
/* 641 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 642 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 644 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 645 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 647 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 648 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 650 */         paramGraphics2D.setPaint(Color.green);
/* 651 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 652 */         this.lA.setLine(this.xi, this.yi - 5.0D, this.xi - 3.0D, this.yi);
/* 653 */         this.hA.setLine(this.xi, this.yi - 5.0D, this.xi + 3.0D, this.yi);
/* 654 */         paramGraphics2D.draw(this.uA);
/* 655 */         paramGraphics2D.draw(this.lA);
/* 656 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 660 */       if ((i > this.parm1 + this.parm2) && (this.mfi_parm1[i] - this.mfiMA_parm2[i] < 0.0F) && (this.mfi_parm1[(i - 1)] - this.mfiMA_parm2[(i - 1)] > 0.0F))
/*     */       {
/* 662 */         this.x1 = this.startPointX;
/* 663 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 664 */         this.y1 = this.p1Y;
/* 665 */         this.y2 = this.p2Y;
/* 666 */         this.u1 = this.x1;
/* 667 */         this.u2 = this.x2;
/* 668 */         this.v1 = this.p11Y;
/* 669 */         this.v2 = this.p22Y;
/*     */ 
/* 671 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 672 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 674 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 675 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 677 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 678 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 680 */         paramGraphics2D.setPaint(Color.red);
/* 681 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 682 */         this.lA.setLine(this.xi, this.yi + 5.0D, this.xi - 3.0D, this.yi);
/* 683 */         this.hA.setLine(this.xi, this.yi + 5.0D, this.xi + 3.0D, this.yi);
/* 684 */         paramGraphics2D.draw(this.uA);
/* 685 */         paramGraphics2D.draw(this.lA);
/* 686 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 690 */       if (this.dateRef == i)
/*     */       {
/* 692 */         paramGraphics2D.setFont(this.ssp9);
/* 693 */         str = ((String)this.sq.date.get(i)).substring(0, 6);
/* 694 */         if (this.mfi_parm1[i] >= this.mfiMA_parm2[i])
/* 695 */           paramGraphics2D.setPaint(Color.green);
/*     */         else {
/* 697 */           paramGraphics2D.setPaint(Color.red);
/*     */         }
/* 699 */         paramGraphics2D.drawString(str, (int)this.startPointX, (int)(this.yScale * 100.0F + 20.0F));
/* 700 */         if (this.noOfDays == 150)
/* 701 */           this.dateRef -= 10;
/*     */         else
/* 703 */           this.dateRef -= 20;
/* 704 */         paramGraphics2D.setFont(this.ssp10);
/*     */       }
/*     */ 
/* 708 */       this.startPointX = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 709 */       this.daysRef += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void main(String[] paramArrayOfString)
/*     */   {
/* 778 */     FileDownloader localFileDownloader = new FileDownloader();
/* 779 */     localFileDownloader.downloadFiles();
/* 780 */     SymQuotes localSymQuotes = new SymQuotes("WIPRO", localFileDownloader.datesToRead, 1, 1, "ns");
/*     */ 
/* 782 */     MFIChart localMFIChart = new MFIChart(localSymQuotes, 14, 10);
/*     */ 
/* 784 */     JFrame localJFrame = new JFrame("Test");
/* 785 */     localJFrame.setDefaultCloseOperation(3);
/* 786 */     localJFrame.getContentPane().add(localMFIChart);
/* 787 */     localJFrame.pack();
/* 788 */     localJFrame.setSize(850, 175);
/* 789 */     localJFrame.setVisible(true);
/*     */   }
/*     */ 
/*     */   public class EastPanel extends JPanel
/*     */   {
/*     */     private JLabel title;
/*     */     private JLabel mfiL;
/*     */     private JLabel mfiMaL;
/*     */     private JLabel l1;
/*     */     private JLabel l2;
/*     */     private JLabel trendL;
/*     */     private ChartHelpButton chb;
/* 721 */     private Font valuesF = new Font("Sanserif", 0, 11);
/* 722 */     public Box buttonsPanel = Box.createHorizontalBox();
/*     */ 
/*     */     public EastPanel()
/*     */     {
/* 726 */       this.title = new JLabel("MFI");
/* 727 */       this.mfiL = new JLabel("MFI[" + MFIChart.this.parm1 + "]: " + MFIChart.this.df.format(MFIChart.this.mfi_parm1[(MFIChart.this.sq.count - 1)]));
/* 728 */       this.mfiMaL = new JLabel("MFI MA[" + MFIChart.this.parm2 + "]: " + MFIChart.this.df.format(MFIChart.this.mfiMA_parm2[(MFIChart.this.sq.count - 1)]));
/* 729 */       this.l1 = new JLabel("Tops:MFI > 80");
/* 730 */       this.l2 = new JLabel("Bottoms:MFI < 20");
/*     */ 
/* 732 */       this.trendL = new JLabel("Trend: " + MFIChart.this.trend);
/* 733 */       this.chb = new ChartHelpButton("http://www.profitindicators.com/home/indicators/mfi.htm", "Help on MFI");
/*     */ 
/* 735 */       this.chb.setFont(this.valuesF);
/*     */ 
/* 737 */       this.mfiL.setFont(this.valuesF);
/* 738 */       this.mfiMaL.setFont(this.valuesF);
/* 739 */       this.trendL.setFont(this.valuesF);
/* 740 */       this.l1.setFont(this.valuesF);
/* 741 */       this.l2.setFont(this.valuesF);
/*     */ 
/* 743 */       this.buttonsPanel.add(this.chb);
/* 744 */       this.buttonsPanel.add(Box.createHorizontalStrut(2));
/* 745 */       this.buttonsPanel.setAlignmentX(0.0F);
/*     */ 
/* 747 */       setLayout(new BoxLayout(this, 3));
/*     */ 
/* 749 */       add(this.title);
/* 750 */       add(this.mfiL);
/* 751 */       add(this.mfiMaL);
/* 752 */       add(new JLabel(" "));
/* 753 */       add(this.trendL);
/* 754 */       add(this.l1);
/* 755 */       add(this.l2);
/* 756 */       add(this.buttonsPanel);
/* 757 */       add(Box.createVerticalGlue());
/*     */ 
/* 759 */       setBackground(new Color(243, 245, 252));
/*     */     }
/*     */ 
/*     */     public void updateValues()
/*     */     {
/* 766 */       this.mfiL.setText("MFI[" + MFIChart.this.parm1 + "]: " + MFIChart.this.df.format(MFIChart.this.mfi_parm1[(MFIChart.this.sq.count - 1)]));
/* 767 */       this.mfiMaL.setText("MFI MA[" + MFIChart.this.parm2 + "]: " + MFIChart.this.df.format(MFIChart.this.mfiMA_parm2[(MFIChart.this.sq.count - 1)]));
/* 768 */       this.trendL.setText("Trend: " + MFIChart.this.trend);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Deebak\Downloads\profitindicatorsv2-05.jar
 * Qualified Name:     MFIChart
 * JD-Core Version:    0.6.0
 */